package org.csu.mypetstore.service;

import org.csu.mypetstore.domain.Category;
import org.csu.mypetstore.domain.Item;
import org.csu.mypetstore.domain.Product;
import org.csu.mypetstore.persistence.CategoryMapper;
import org.csu.mypetstore.persistence.ItemMapper;
import org.csu.mypetstore.persistence.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CatalogService {
    //业务逻辑层调用数据访问层
    @Autowired
    private CategoryMapper categoryMapper;
    @Autowired
    public ProductMapper productMapper;
    @Autowired
    public ItemMapper itemMapper;

    public List<Category> getCategoryList() {
        return categoryMapper.getCategoryList();
    }

    public Category getCategory(String categoryId) {
        return categoryMapper.getCategory(categoryId);
    }

    public List<Product> getProductListByCategory(String categoryId){return productMapper.getProductListByCategory(categoryId);}

    public Product getProduct(String productId){
        return productMapper.getProduct(productId);
    }

    public List<Item> getItemListByProduct(String productId){return itemMapper.getItemListByProduct(productId);}

    public Item getItem(String itemId){return itemMapper.getItem(itemId);}

    public List<Item> getAllItem(){return itemMapper.getAllItem();}

}
